package oer.halk.intercept_demo;

import oer.halk.intercept_demo.filter.BodyReaderFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

/**
 * 统一配置拦截器demo
 *
 * @Author zhuhao
 * @Date 2022/1/26 14:47
 * @desc
 */
@SpringBootApplication
public class InterceptDemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(InterceptDemoApplication.class);
    }

    @Bean
    public FilterRegistrationBean<BodyReaderFilter> Filters() {
        FilterRegistrationBean<BodyReaderFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new BodyReaderFilter());
        registrationBean.addUrlPatterns("/*");
        registrationBean.setName("bodyReaderFilter");
        return registrationBean;
    }
}
